import router from '@/router'
import { removeItem } from '@/utils/cookieUtil'
import { Message } from "element-ui"

export function resError(res) {
    Message.error(res.message)
    if (res.data == '抱歉，您没有访问权限' || res.data == 'Full authentication is required to access this resource') {
        removeItem("token")
        setTimeout(() => {
            router.push('/index')   
        }, 500)
    }
}

export function getSize(size) {
    if(size == null || size == '') return ""
    if (size > 1073741824) return (size / 1073741824).toFixed(2) + "G";
    else if (size > 1048576) return (size / 1048576).toFixed(2) + "MB";
    else if (size > 1024) return (size / 1024).toFixed(2) + "KB";
    else return size.toFixed(2) + "B";
}


